package com.tzpay.tzpay.api;

import com.tzpay.tzpay.bean.UserInfo;
import com.tzpay.tzpay.common.ConstValue;
import com.tzpay.tzpay.utils.CryptTool;
import com.tzpay.tzpay.utils.Utils;

/**
 * Created by chenfeiyue on 16/3/15.
 */
public class OrderQueryRequest {

    public String merchantId = UserInfo.getInstance().getMerchantNo();
    public String orderNo;
    public String orderReqNo;
    public String orderDate = Utils.getDateTime();
    public String mac;

    public String calculateMac() {
        StringBuilder sb = new StringBuilder();//组装mac加密明文串
        sb.append("MERCHANTID=").append(merchantId);
        sb.append("&ORDERNO=").append(orderNo);
        sb.append("&ORDERREQNO=").append(orderReqNo);
        sb.append("&ORDERDATE=").append(orderDate);
        sb.append("&KEY=").append(UserInfo.getInstance().getMerchantDataKey());//此处是商户的key
        String enMac = "";
        try {
            System.err.println(sb.toString());
            enMac = CryptTool.md5Digest(sb.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return enMac;
    }
}
